package com.pyk.config;

import com.pyk.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//这个是配置类 所以加配置类的注解 里面也包含了 comment 注解

/**
 * 这里是配置拦截器，哪些网页该拦截，哪些不该
 * 在程序中属于第一步
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    //依赖注入
    @Autowired
    private LoginInterceptor loginInterceptor;

    /**
     * 重写方法
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).excludePathPatterns("/user/login","/user/register");

    }
}
